﻿/*
* @Author： whg
* @Date : 2021-1-19
* @Desc : 
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using XNodeEditor;
using XNode;
[XNodeEditor.NodeEditor.CustomNodeEditor(typeof(CameraNode))]
public class CameraEditor : NodeEditor
{
    private CameraNode node;
    public override void OnBodyGUI()
    {
        //base.OnBodyGUI();
        serializedObject.Update();
        if (node == null) node = target as CameraNode;

        NodeEditorGUILayout.PortField(target.GetInputPort("upLink"));
        //NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("upLink"));
        EditorGUILayout.Space();
        NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("wait"));
        EditorGUIUtility.labelWidth = 120;
        NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("isMove"));
        if (node.isMove)
        {
            EditorGUI.indentLevel++;
            NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("CameraMove"));
            EditorGUI.indentLevel--;
        }
        NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("isRotate"));
        if (node.isRotate)
        {
            EditorGUI.indentLevel++;
            NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("CameraRotate"));
            EditorGUI.indentLevel--;
        }
        NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("isZoom"));
        if (node.isZoom)
        {
            EditorGUI.indentLevel++;
            NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Zoom_MotionType"));
            if (node.Zoom_MotionType != CameraNode.MotionType.直接切换)
            {
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Zoom_time"));
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Zoom_target"));
            }
            else
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Zoom_target"));
            
            EditorGUI.indentLevel--;
        }
        NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("isFollow"));
        if (node.isFollow)
        {
            EditorGUI.indentLevel++;
            NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("follow_init"));
            if(!node.follow_init)
            {
                NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("follow_time"));
            }
            NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("follow_target"));
            NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("follow_ins_id"));
            NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("RootOffset"));
            NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("RootRotate"));
            NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("ChildOffset"));
            NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("ChildRotate"));
            NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("Lookat"));
            EditorGUI.indentLevel--;
        }
        NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("isShake"));
        if (node.isShake)
        {
            EditorGUIUtility.labelWidth = 160;
            EditorGUI.indentLevel++;
            NodeEditorGUILayout.PropertyField(serializedObject.FindProperty("CameraShake"));
            EditorGUI.indentLevel--;
        }
        NodeEditorGUILayout.PortField(target.GetOutputPort("downLink"));
        serializedObject.ApplyModifiedProperties();
    }
    public override int GetWidth()
    {
        return 250;
    }
}
